/***************************************************************************
 *            tcpserver_test.c
 *
 *  Fri May 25 21:26:31 2007
 *  Copyright  2007  kf701
 *  Email <kf701.ye AT gmail.com>
 ****************************************************************************/


#include "kf701.h"

/* The best idea for the run func is:
 * push data to other thread data queue
 */
void run(int fd, uint8_t *data, uint32_t size)
{
	data[size] = 0;
	sys_debug("%s,%d: socket data = %s\n", __FILE__, __LINE__, data);
	uint8_t buf[10];
	rand_string( buf, sizeof(buf) );
	write( fd, buf, sizeof(buf) );
}

int main()
{
	debug_verbose = 4;
	sys_debug("tcp listen port 8080 ...\n");
	tcp_server_select( 8080, 1024, run );
	return 0;
}
